package com.sysftech.scaffold.mvc.single.web;

import com.sysftech.scaffold.mvc.single.dao.UsersMapper;
import com.sysftech.scaffold.mvc.single.entity.Users;
import jakarta.annotation.Resource;
import lombok.extern.log4j.Log4j2;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Log4j2
public class UserController {

    @Resource
    private UsersMapper usersDao;

    @Resource
    private
    RedisTemplate<String, String> redisTemplate;

    @GetMapping("/list")
    public List<Users> list(){
        return usersDao.selectList(null);
    }

    @GetMapping("/redis/{key}")
    public String hello(@PathVariable("key") String key){
        redisTemplate.opsForValue().set(key, "1990411");
        return redisTemplate.opsForValue().get(key);
    }
}
